import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/pages/login/index'
import Index from '@/pages/index/index'
import API from '@/server/userConfig';
import store from '@/store/index';

Vue.use(Router)

const originalPush = Router.prototype.push;
   Router.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
};

export default new Router({
  routes: [
    {
      path: '/login',
      name: 'login',
      component: Login,
      meta: {
        title: '登录'
      }
    }, {
      path: '/index',
      alias: '/',
      name: 'index',
      component: Index,
      redirect: '/ncCheckList', // 重定向，第一次进入就进入view，不添加的话第一次进入下面是空白
      children: [
        {
          path: '/ncCheckList',
          name: 'ncCheckList',
          component: () => import('@/pages/ncCheckList'),
          meta: {
            title: '华中数控系统成套检测工具'
          }
        },
        {
          path: '/systemSearch',
          name: 'systemSearch',
          component: () => import('@/pages/systemSearch'),
          meta: {
            title: '系统检测'
          }
        },
        {
          path: '/dataStatistics',
          name: 'dataStatistics',
          component: () => import('@/pages/dataStatistics'),
          meta: {
            title: '数据统计'
          }
        },
        {
          path: '/dataTrendChart',
          name: 'dataTrendChart',
          component: () => import('@/pages/dataTrendChart'),
          meta: {
            title: '数据趋势图'
          }
        },
        {
          path: '/outPutDetail',
          name: 'outPutDetail',
          component: () => import('@/pages/outPutDetail'),
          meta: {
            title: '出货详情'
          }
        },
      ]
    },
    {
      path: '*',
      name: '404',
      component: () => import('@/pages/404/404')
    }
  ]
})
